using System;
using System.Diagnostics.Contracts;

namespace OpenWaves.ActivityFeed.Web
{
    public class CommentDto
    {
        public string Id { get; set; }
        public string Text { get; set; }
        public DateTime PublishedOn { get; set; }
        public UserDto Publisher { get; set; }

        public static CommentDto FromComment(Comment comment, IUserProfileProvider userProfileProvider)
        {
            Contract.Requires<ArgumentNullException>(comment != null);
            Contract.Requires<ArgumentNullException>(userProfileProvider != null);

            return new CommentDto()
                       {
                           Id = comment.Id,
                           Text = comment.Text,
                           PublishedOn = comment.PublishedOn,
                           Publisher = UserDto.FromUserId(comment.PublishedBy, userProfileProvider)
                       };
        }
    }
}